#include <stdio.h>
#include <string.h>

int main() {
	char a[100];
	gets(a);
	int len = strlen(a);
	int k = 0;
	scanf("%d", &k);

	for (int i = 0; i < k; i++) {
		char first = a[0];
		int j = 1;
		for (j = 1; j < len; j++) {
			a[j - 1] = a[j];
		}
		a[j - 1] = first;
	}

	puts(a);
	return 0;
}